define([ "Zepto", "underscore", "Backbone", "Handlebars",
         "views/student/courseitemview",
         "views/common/menuview"
         ], function($, _, Backbone, Handlebars, CourseItemView, MenuView) {

	var CoursesView = Backbone.View.extend({

		initialize : function() {
			this.model.bind("reset", this.render, this);
		},

		render : function(eventName) {
			 $(this.el).empty();
			 
			// menu top
			this.menutop = new MenuView({
				el : $('#menu', this.el),
				model : this.model
			});
			this.menutop.render();

			 ﻿_.each(this.model.models,
					function(course) {
						//alert('course: ' + course.get('corso').nome); not docente
						﻿$(this.el).append(new CourseItemView({
							tagName : 'a', //Crea un nuovo tag <a> invece di usarne uno già presente nel DOM
							attributes : {
								'href' : '#courses/'+course.get('corso').objectId
							},
							model : course
						}).render().el);
					 },
					 this);
			 var scroll2 = new iScroll('corsi',
                                  { useTransition:false,
                                    checkDOMChanges: true,
                                    hideScrollbar: true,
                                    fixedScrollbar:true }
                                );
		}

	});
	

	return CoursesView;
});
